package com.fac.controller.user;

import com.fac.dto.LeaseOrderCreateDTO;
import com.fac.dto.LeaseOrderPageQueryDTO;
import com.fac.result.PageResult;
import com.fac.result.Result;
import com.fac.service.LeaseOrderService;
import com.fac.vo.LeaseOrderCreateVO;
import com.fac.vo.LeaseOrderVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 用户端租赁订单Controller
 */
@RestController("userLeaseOrderController")
@RequestMapping("/user/leaseOrders")
@Api(tags = "用户端-租赁订单接口")
@Slf4j
public class LeaseOrderController {

    @Autowired
    private LeaseOrderService leaseOrderService;

    /**
     * 创建租赁订单
     *
     * @param createDTO 创建订单信息
     * @return 创建结果
     */
    @PostMapping
    @ApiOperation("创建租赁订单")
    public Result<LeaseOrderCreateVO> create(@RequestBody LeaseOrderCreateDTO createDTO) {
        log.info("创建租赁订单：{}", createDTO);
        LeaseOrderCreateVO orderVO = leaseOrderService.create(createDTO);
        return Result.success(orderVO);
    }

    /**
     * 查询我的租赁订单
     *
     * @param queryDTO 查询条件
     * @return 分页结果
     */
    @GetMapping
    @ApiOperation("查询我的租赁订单")
    public Result<PageResult> page(LeaseOrderPageQueryDTO queryDTO) {
        log.info("查询我的租赁订单：{}", queryDTO);
        PageResult pageResult = leaseOrderService.pageQuery(queryDTO);
        return Result.success(pageResult);
    }
} 